package day23.Person;

import java.util.Arrays;

public class Person implements Comparable<Person> {
    private String name;
    public Person(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    @Override
    public int compareTo(Person o) {
        return this.name.compareTo(o.getName());
    }
}
 class SortReferenceArray {
    public static void main(String[] args) {
        Person[] array = {new Person("Alice"), new Person("Bob"), new Person("Aharlie")};
        System.out.println("排序前的数组：");
        for (Person person : array) {
            System.out.println(person.getName());
        }
        Arrays.sort(array);
        System.out.println("排序后的数组：");
        for (Person person : array) {
            System.out.println(person.getName());
        }
    }
}